import fetch from '@/utils/request.js'

// 获取验证码
function apigetCode (mobile) {
  return fetch({
    url: '/au/code',
    method: 'post',
    data: {
      mobile: mobile
    }
  })
}
// 登录页面
function apiLogin ({ mobile, code }) {
  return fetch({
    url: '/au/login',
    method: 'post',
    data: {
      mobile,
      code
    }
  })
}
// 刷新获取用户信息
function apiGetInfo () {
  return fetch({
    url: '/au/info',
    method: 'get',
    needToken: true
  })
}
// 修改用户信息
function apiEditInfo ({ nickname, intro, gender, avatar, position, area }) {
  return fetch({
    url: '/au/edit',
    method: 'post',
    needToken: true,
    data: {
      nickname,
      intro,
      gender,
      avatar,
      position,
      area
    }
  })
}
// 文件上传
function apiUpload (file) {
  const fd = new FormData()
  fd.append('files', file)
  return fetch({
    url: '/upload',
    method: 'post',
    needToken: true,
    data: fd
  })
}
export { apigetCode, apiLogin, apiGetInfo, apiEditInfo, apiUpload }
